home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_gen / jav503.zip / CIRCLE.JAV < prev    next >
Text File  |  1996-03-29  |  1KB  |  76 lines

  1. // -[KeepHeading]-
  2.  
  3.  
  4. // -[Copyright]-
  5.  
  6. /**
  7.  * (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights
  8.  * reserved.
  9.  */
  10. import java.lang.*;
  11.  
  12.  
  13. // -[KeepBeforeClass]-
  14. import java.awt.*;
  15.  
  16.  
  17. // -[Class]-
  18.  
  19. /**
  20.  * @jTitle           Circle
  21.  * @jOverridability  can be overridden
  22.  * @jDescription
  23.  * Describe here
  24.  * 
  25.  * @see              Shape
  26.  */
  27. public 
  28. class Circle extends Shape
  29. {
  30. // -[KeepWithinClass]-
  31.  
  32.  
  33. // -[Fields]-
  34.  
  35.  
  36.  
  37. /**
  38.  * The radius of the circle
  39.  */
  40. protected int radius;
  41.  
  42.  
  43. // -[Methods]-
  44.  
  45. /**
  46.  * Constructs a circle object with given position and radius.
  47.  */
  48. public Circle(int initX, int initY, int initRadius) {
  49.         super(initX, initY);
  50.         radius = initRadius;
  51. }
  52.  
  53. /**
  54.  * Abstract method overridden in derived classes to paint objects.
  55.  */
  56. public void show(Graphics g)
  57. {
  58.     // Get current color
  59.     Color oldColor = g.getColor();
  60.  
  61.     // Change to red
  62.     g.setColor(Color.red);
  63.  
  64.     // Draws a circle within the rectangle specified with
  65.     // top, left point and width and height
  66.     g.fillOval(x, y, radius * 2, radius * 2);
  67.  
  68.     // Restore old color - it's always good practice to leave things the
  69.     // way we found them - think of your kid's future!
  70.     g.setColor(oldColor);
  71. }
  72.  
  73. }
  74.  
  75.  
  76.